call the base classes' object_init_func for derived objects with the
authorTim Janik <timj@gtk.org>
Sun, 12 Jul 1998 04:13:02 +0000 (04:13 +0000)
committerTim Janik <timj@src.gnome.org>
Sun, 12 Jul 1998 04:13:02 +0000 (04:13 +0000)
Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
        object_init_func for derived objects with the object's ->klass field
        still pointing to the corresponding base class, otherwise overridden
        class functions could get called with partly-initialized objects.
        (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktypeutils.c

index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index db0c2a18e2c32b1e3c561cf552458cfdd3ea1981..ed117862893b66813718640b70a3982b4779a7f8 100644 (file)
@@ -1,3 +1,11 @@
+Sun Jul 12 05:59:26 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_new): call the base classes'
+       object_init_func for derived objects with the object's ->klass field
+       still pointing to the corresponding base class, otherwise overridden
+       class functions could get called with partly-initialized objects.
+       (change from Tero Pulkkinen <terop@modeemi.cs.tut.fi>).
+
 Sun Jul 12 02:47:35 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkobject.h:
index 44f240ef45fdf9d4e0c6463d3980be6e5361134e..64a7af5782844e3ef5ba0976c76376fb5e1ceb02 100644 (file)
@@ -339,18 +339,26 @@ gtk_type_new (GtkType type)
     }
   else
     object = g_malloc0 (node->type_info.object_size);
-  object->klass = klass;
 
+  /* we need to call the base classes' object_init_func for derived
+   * objects with the object's ->klass field still pointing to the
+   * corresponding base class, otherwise overridden class functions
+   * could get called with partly-initialized objects.
+   */
   for (i = node->n_supers; i > 0; i--)
     {
       GtkTypeNode *pnode;
 
       LOOKUP_TYPE_NODE (pnode, node->supers[i]);
       if (pnode->type_info.object_init_func)
-       (* pnode->type_info.object_init_func) (object);
+       {
+         object->klass = pnode->klass;
+         pnode->type_info.object_init_func (object);
+       }
     }
+  object->klass = klass;
   if (node->type_info.object_init_func)
-    (* node->type_info.object_init_func) (object);
+    node->type_info.object_init_func (object);
 
   return object;
 }